const { writeFile, readFile, fsExistsSync } = require("../../app/util");
const { getDefaultBlock, themeList } = require("../tool/util");

// page.json 多个转单页页面配置
function pageSplit(template) {
    const pageContent = JSON.parse(readFile(`./src/theme/${template}/lib/config/page.json`));
    pageContent.forEach((element) => {
        if (element.sections.length > 1) {
            writeFile(`./src/theme/${template}/lib/config/${element.route.replace("/", "_")}.json`, JSON.stringify(element.sections, "", "\t"));
        }
    });
}

function buildAllConfig() {
    const list = themeList();
    list.forEach((item) => {
        if (fsExistsSync(`./src/theme/${item}/config`)) {
            pageSplit(item);
        }
    });
}

buildAllConfig()

// pageSplit("ambianimaless20")
